﻿//到货通知单
$(function(){
	//搜索
	$('.searchBar').click(function(){
		var thisform=$(this).parent('form');
		var order_no=thisform.find('input[name=order_no]').val();
		var goods_no=thisform.find('input[name=goods_no]').val();
		var start_time=thisform.find('input[name=start_time]').val();
		var end_time=thisform.find('input[name=end_time]').val();

		$('#Datagrid').datagrid('options').pageNumber=1;//设置页码初始值为1
		$('#Datagrid').datagrid({ 
			queryParams:{
				order_no:order_no,
				goods_no:goods_no,
				start_time:start_time,
				end_time:end_time
			}
		});
	})
	//导出Excel
	$('.excelOut').click(function(){
		var thisform=$(this).parent('form');
		var order_no=thisform.find('input[name=order_no]').val();
		var goods_no=thisform.find('input[name=goods_no]').val();
		var start_time=thisform.find('input[name=start_time]').val();
		var end_time=thisform.find('input[name=end_time]').val();
		
		getarrivalUrl=getarrivalUrl+"&excel=1";
		
		if(order_no!=""){
			getarrivalUrl=getarrivalUrl+"&order_no="+order_no;
		}
		if(goods_no!=""){
			getarrivalUrl=getarrivalUrl+"&goods_no="+goods_no;
		}
		if(start_time!=""){
			getarrivalUrl=getarrivalUrl+"&start_time="+start_time;
		}
		if(end_time!=""){
			getarrivalUrl=getarrivalUrl+"&end_time="+end_time;
		}
		
		window.location.href=getarrivalUrl;
	})
	$('#Datagrid').datagrid({
		//url:getarrivalUrl+"?randnum="+Math.floor(Math.random()*1000000),
		queryParams:{
			status:0//未审核
		},
		url:getfreezUrl,
		title:'冻结库存记录',
		fitColumns:true,
		rownumbers:true,
		pageSize:25,
		pageNumber:1,
		pageList:[5,10,15,20,25,30,40,50],
		columns:[[
		{field:'id',title:'id',checkbox:true},
		{field:'goods_id',title:'商品ID',sortable:true},
		{field:'goods_no',title:'商品编号'},
		{field:'freez_amount',title:'冻结数量'},
		{field:'storage_amount',title:'更新后库存数量'},
		{field:'time',title:'操作时间',sortable:true},
		{field:'times',title:'递归次数',sortable:true},
		]],
		onLoadError:function(data){
			var info=eval('('+data.responseText+')');
			$.messager.confirm('错误提示',info.message,function(r){
				var tab=$('#Tabs').tabs('getSelected');
				var index=$('#Tabs').tabs('getTabIndex',tab);
				$('#Tabs').tabs('close',index);
			});
		},
		rowStyler:function(index,row){
			if (row.color==0){
				return 'background-color:pink;color:blue;font-weight:bold;';
			}
		},
		pagination:true,
		fit:true,
	});
});
authUserObj={
	showAll:function(){
		$('#Datagrid').datagrid({ queryParams:'status:0'});
	}
}